﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Web;
using Hxsoft.AppV1;
using Hxsoft.AppV1.Module;

namespace Hxsoft.AppV1.Admin
{
	public partial class Helper
	{
		/// <summary>
		/// 检测用户是否登录。
		/// </summary>
		public static Guid CheckLogin()
		{
			Guid? userId = Users.CurrentUserId;
			if (userId.HasValue)
				return userId.Value;
			else
			{
				HttpContext context = HttpContext.Current;
				context.Response.Clear();

				string responseHtml = @"<script language=""javascript"" type=""text/javascript"">var win = opener ? opener : top;win.top.location.href=""" + context.Request.ApplicationPath + @"/Default.aspx""; if(opener) close();</script>";
				context.Response.Write(responseHtml);

				context.Response.End();
			}

			return default(Guid);
		}

		public static string GetPagerCustomInfoHtml<T>(PaginationInfo<T> pageInfo) where T : ICollection, IEnumerable, new()
		{
			return Res.Pager_CustomInfoHTML.Replace("{0}", pageInfo.CurrentPage.ToString())
				.Replace("{1}", pageInfo.PageCount.ToString())
				.Replace("{2}", pageInfo.CurrentPageLimit.Lower.ToString())
				.Replace("{3}", pageInfo.CurrentPageLimit.Upper.ToString());
		}

		/// <summary>
		/// 命令类别。
		/// </summary>
		public enum CommandType
		{
			Delete,
			Remove,
			Copy,
			CopyMove,
			SetEffectiveState,			
			SetOpenCommentState,
			SetRecommend,
			RemoveRecommend, 
			SetHomeShow,
			Recover,
			AddToWapCompany,
			RemoneFromWapCompany,
			SetOpenMessageBoard,
			SetTradeStatus
		}

		public const string InfoResourceCopyName_PhotoSubjectImg = "110X110";
		public const string InfoResourceCopyName_PhotoImg = "500X400";		

		public static string GetMainSiteList(string userName)
		{			
			return @"<div class=""siteDetail""></div>";				
		}


	}
}
